/*

before running the programm you should install the following stata commands : 
gtstyle, spmap, pscalc, estout, sgmediation2 and outreg2

*/

********************************************************************************
*								DATA DESCRIPTION
********************************************************************************


/*
ictd_taxinsc							: Taxes (including social contributions)
ictd_ntradetax							: Non trade taxes
ictd_directtax							: Direct taxes
realtaxperccapita						: Real tax per capita
statehiste01n							: Statehist (1% discount)
statehiste001n							: Statehist (0.1% discount)
statehiste02n							: Statehist (2% discount)
statehiste1_1950						: Statehist 1-1950 CE (1% discount)
statehiste1500							: Statehist in 1500 CE (1% discount)
s01n_mig1 								: Ancestry-Adjusted Statehist (1% discount)
catho80 								: Catholics proportion
muslim80								: Muslims proportion
protmg80 								: Protestants proportion
ln_elev 								: Mean Elevation
arable 									: Percentage Arable Land
temp									: Temperature 
ln_precip 								: Precipitation
cen_lat 								: latitude of country centroid
landlocked 								: Landlocked
suitavg									: Land Suitability
continent								: Continent categorical variable
ln_gdppercapita							: GDP per capita (in log)
vdem_corr								: Political corruption index
wbgi_gee								: Government Effectiveness, Estimate
vdem_egaldem							: Egalitarian democracy index
inc										: Income level cotegorical variable
wdi_oilrent								: Oil rents (% of GDP)
wdi_inflation							: Inflation, consumer prices (annual %)
wdi_trade								: Trade (% of GDP)
ied_dge									: Dynamic general equilibrium model-based (DGE) estimates of informal output (% of GDP)
tr2										: Technology Adoption in 1 CE
t2 										: Transportation technology in 1 CE
c2 										: Communication technology in 1 CE
mt2 									: Military technology in 1 CE
mw2 									: Industry technology in 1 CE
legor_uk 								: British legal origin dummy			
legor_fr 								: French legal origin dummy
legor_sc 								: Scandinavian legal origin dummy
acdummy 								: Colonial Dummy
fh_rol									: Rule of Law
wbgi_pve								: Political Stability and Absence of Violence/Terrorism, Estimate
pwt_hci									: Human capital index, see note hc
wdi_popurb								: Urban population (% of total population)
wdi_lfprf								: Labor force participation rate, female (% of female pop. ages 15-64) (ILO)
wdi_popden								: Population density (people per sq. km of land area)
mean_relgendist_fst_1500_UK 			: mean of genetic distance to the world frontier (UK) in 1500 CE
mt1 									: military technology in 1 CE

*/



grstyle init

grstyle set plain

grstyle set color Accent: p#bar p#barline 

grstyle set inten 30: bar

use "path\database.dta"




**************************************************
* DATA AND METHODOLOGY SECTION
**************************************************

/*spmap statehiste01n using "path\coord_mercator_world.dta", id( na_id_world ) fcolor(Blues2) osize(vvthin vvthin vvthin vvthin) ndsize(vvthin) ndfcolor(gray) legstyle(1) legend(ring(2) position(6)) clnumber(4)

graph export "Figure_1.png", replace*/


twoway (scatter ictd_taxinsc statehiste01n, mlabel(Names) sort ) (lfit ictd_taxinsc statehiste01n ), legend(ring(2) position(6)) saving(linear, replace)



********************************************************************************
*			4.1.	Baseline results
********************************************************************************

eststo eq1: qui reg ictd_taxinsc statehiste01n , r
estat ovtest
eststo eq2: qui reg ictd_taxinsc statehiste01n catho80 muslim80 protmg80, r
estat ovtest
psacalc delta statehiste01n
eststo eq3: qui reg ictd_taxinsc statehiste01n catho80 muslim80 protmg80 ln_elev arable temp ln_precip cen_lat landlocked suitavg, r
estat ovtest
psacalc delta statehiste01n
eststo eq4: qui reg ictd_taxinsc statehiste01n catho80 muslim80 protmg80 ln_elev arable temp ln_precip cen_lat landlocked suitavg i.continent, r
estat ovtest
psacalc delta statehiste01n

esttab using Table1, se title(Table 1. Effect of State antiquity on fiscal capacity, baseline – OLS ) nonumbers r2 sca(N F) sfmt(0 3 3) mtitles("(1)" "(2)" "(3)" "(4)") order(statehiste01n c.statehiste01n#c.statehiste01n ) label nodep nogaps compress star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) nonotes addnotes(" p < 0.10, ** p < 0.05, *** p < 0.01" "Huber-White robust standard errors in parentheses.") rtf replace
eststo clear

********************************************************************************
*		4.2.	The assessment of the potential transmission channels
********************************************************************************

eststo eq1: qui sgmediation2 ictd_taxinsc, iv(statehiste01n) cv(catho80 muslim80 protmg80 ln_elev arable temp ln_precip cen_lat landlocked suitavg i.continent) mv (ln_gdppercapita)
eststo eq2: qui sgmediation2 ictd_taxinsc, iv(statehiste01n) cv(catho80 muslim80 protmg80 ln_elev arable temp ln_precip cen_lat landlocked suitavg i.continent) mv (vdem_corr)
eststo eq3: qui sgmediation2 ictd_taxinsc, iv(statehiste01n) cv(catho80 muslim80 protmg80 ln_elev arable temp ln_precip cen_lat landlocked suitavg i.continent) mv (wbgi_gee)
eststo eq4: qui sgmediation2 ictd_taxinsc, iv(statehiste01n) cv(catho80 muslim80 protmg80 ln_elev arable temp ln_precip cen_lat landlocked suitavg i.continent) mv (vdem_egaldem)


esttab using Table2, se nonumbers nonumbers sca(N ar_zstat g_zstat s_zstat ind_eff dir_eff tot_eff) sfmt(0 3 3) drop(catho80 muslim80 protmg80 ln_elev arable temp ln_precip cen_lat landlocked suitavg *.continent) label nodep nogaps mtitles("(1)" "(2)" "(3)" "(4)" "(5)" "(6)" "(7)" "(8)" "(9)" "(10)") compress star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) nonotes addnotes(" p < 0.10, ** p < 0.05, *** p < 0.01" "Huber-White robust standard errors in parentheses.") rtf replace
eststo clear //this table is construct manually using the results of estimates

********************************************************************************
*		5.1.	Robustness to alternative measures of state history
********************************************************************************
eststo eq2: qui reg ictd_taxinsc statehiste001n catho80 muslim80 protmg80 ln_elev arable temp ln_precip cen_lat landlocked suitavg i.continent , r
psacalc delta statehiste001n
estat ovtest

eststo eq4: qui reg ictd_taxinsc statehiste02n catho80 muslim80 protmg80 ln_elev arable temp ln_precip cen_lat landlocked suitavg i.continent , r
psacalc delta statehiste02n
estat ovtest

eststo eq6: qui reg ictd_taxinsc statehiste1_1950 catho80 muslim80 protmg80 ln_elev arable temp ln_precip cen_lat landlocked suitavg i.continent, r
psacalc delta statehiste1_1950
estat ovtest

eststo eq8: qui reg ictd_taxinsc statehiste1500 catho80 muslim80 protmg80 ln_elev arable temp ln_precip cen_lat landlocked suitavg i.continent, r
psacalc delta statehiste1500_01n
estat ovtest

eststo eq10: qui reg ictd_taxinsc s01n_mig1 catho80 muslim80 protmg80 ln_elev arable temp ln_precip cen_lat landlocked suitavg i.continent, r
psacalc delta s01n_mig1
estat ovtest

esttab using Table3, se title(Table 3. Effect of state history, alternative measures of state history - OLS) drop(catho80 muslim80 protmg80 ln_elev arable temp ln_precip cen_lat landlocked suitavg *.continent) nonumbers r2 sca(N F) sfmt(0 3 3) mtitles("(1)" "(2)" "(3)" "(4)") label nodep nogaps compress star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) nonotes addnotes(" p < 0.10, ** p < 0.05, *** p < 0.01" "Huber-White robust standard errors in parentheses.") replace rtf
eststo clear

********************************************************************************
*		5.2.	Robustness analysis to alternative measures of fiscal capacity
********************************************************************************

eststo eq1: qui reg ictd_ntradetax statehiste01n catho80 muslim80 protmg80 ln_elev arable temp ln_precip cen_lat landlocked suitavg i.continent , r
estat ovtest
psacalc delta statehiste01n

eststo eq2: qui reg ictd_directtax statehiste01n catho80 muslim80 protmg80 ln_elev arable temp ln_precip cen_lat landlocked suitavg i.continent , r
estat ovtest
psacalc delta statehiste01n

eststo eq3: qui reg realtaxperccapita statehiste01n catho80 muslim80 protmg80 ln_elev arable temp ln_precip cen_lat landlocked suitavg i.continent , r
estat ovtest
psacalc delta statehiste01n

esttab using Table4, se title(Table 4. Effect of state history, alternative measures of fiscal capacity - OLS) drop(catho80 muslim80 protmg80 ln_elev arable temp ln_precip cen_lat landlocked suitavg *.continent) nonumbers r2 sca(N F) sfmt(0 3 3) mtitles("(1)" "(2)" "(3)" "(4)") label nodep nogaps compress star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) nonotes addnotes(" p < 0.10, ** p < 0.05, *** p < 0.01" "Huber-White robust standard errors in parentheses.") rtf replace
eststo clear


********************************************************************************
*		5.3.	Heterogeneity issues
********************************************************************************

reg ictd_taxinsc c.statehiste01n##i.continent catho80 muslim80 protmg80 ln_elev arable temp ln_precip cen_lat landlocked suitavg, r
margins continent , dydx(  statehiste01n  )
marginsplot, recast(scatter) recastci(rcap) yline(0) title("Effect by region", box bexpand size(medium)) saving(HE1, replace)

reg ictd_taxinsc c.statehiste01n##i.inc catho80 muslim80 protmg80 ln_elev arable temp ln_precip cen_lat landlocked suitavg, r
margins inc , dydx(  statehiste01n  )
marginsplot, recast(scatter) recastci(rcap) yline(0) title("Effect by level of income", box bexpand size(medium)) saving(HE2, replace)

graph combine "HE1"  "HE2", cols(2) saving(scat, replace)

esttab using TableA1, se title(Table A1. Effect of state history by level of income and by region - OLS) drop(catho80 muslim80 protmg80 ln_elev arable temp ln_precip cen_lat landlocked suitavg) nonumbers r2 sca(N F) sfmt(0 3 3) mtitles("(1)" "(2)" "(3)" "(4)") label nodep nogaps compress star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) nonotes addnotes(" p < 0.10, ** p < 0.05, *** p < 0.01" "Huber-White robust standard errors in parentheses.") rtf replace


********************************************************************************
*		5.4.	Sensitivity to historical determinants 
********************************************************************************

eststo eq1: qui reg ictd_taxinsc statehiste01n catho80 muslim80 protmg80 ln_elev arable temp ln_precip cen_lat landlocked suitavg i.continent tr2 , r
estat ovtest
psacalc delta statehiste01n

eststo eq2: qui reg ictd_taxinsc statehiste01n catho80 muslim80 protmg80 ln_elev arable temp ln_precip cen_lat landlocked suitavg i.continent t2 c2 mt2 mw2 , r
estat ovtest
psacalc delta statehiste01n

eststo eq3: qui reg ictd_taxinsc statehiste01n catho80 muslim80 protmg80 ln_elev arable temp ln_precip cen_lat landlocked suitavg i.continent legor_uk legor_fr legor_sc , r
estat ovtest
psacalc delta statehiste01n

eststo eq4: qui reg ictd_taxinsc statehiste01n catho80 muslim80 protmg80 ln_elev arable temp ln_precip cen_lat landlocked suitavg i.continent acdummy , r
estat ovtest
psacalc delta statehiste01n

eststo eq5: qui reg ictd_taxinsc statehiste01n catho80 muslim80 protmg80 ln_elev arable temp ln_precip cen_lat landlocked suitavg i.continent t2 c2 mt2 mw2 legor_uk legor_fr legor_sc acdummy , r
estat ovtest
psacalc delta statehiste01n


esttab using Table5, se title(Table 5. Effect of State history, adding historical controls – OLS ) drop(catho80 muslim80 protmg80 ln_elev arable temp ln_precip cen_lat landlocked suitavg *.continent) nonumbers r2 sca(N F) sfmt(0 3 3) mtitles("(1)" "(2)" "(3)" "(4)") label nodep nogaps compress star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) nonotes addnotes(" p < 0.10, ** p < 0.05, *** p < 0.01" "Huber-White robust standard errors in parentheses.") rtf replace
eststo clear


********************************************************************************
*		5.5.	Sensitivity to economic determinants
********************************************************************************

eststo eq1: qui reg ictd_taxinsc statehiste01n catho80 muslim80 protmg80 ln_elev arable temp ln_precip cen_lat landlocked suitavg i.continent ln_gdppercapita , r
estat ovtest
psacalc delta statehiste01n

eststo eq2: qui reg ictd_taxinsc statehiste01n catho80 muslim80 protmg80 ln_elev arable temp ln_precip cen_lat landlocked suitavg i.continent wdi_oilrent , r
estat ovtest
psacalc delta statehiste01n

eststo eq3: qui reg ictd_taxinsc statehiste01n catho80 muslim80 protmg80 ln_elev arable temp ln_precip cen_lat landlocked suitavg i.continent wdi_inflation , r
estat ovtest
psacalc delta statehiste01n

eststo eq4: qui reg ictd_taxinsc statehiste01n catho80 muslim80 protmg80 ln_elev arable temp ln_precip cen_lat landlocked suitavg i.continent wdi_trade , r
estat ovtest
psacalc delta statehiste01n

eststo eq5: qui reg ictd_taxinsc statehiste01n catho80 muslim80 protmg80 ln_elev arable temp ln_precip cen_lat landlocked suitavg i.continent ied_dge , r
estat ovtest
psacalc delta statehiste01n


esttab using Table6, se title(Table 6. Effect of State history, adding economic determinants – OLS) drop(catho80 muslim80 protmg80 ln_elev arable temp ln_precip cen_lat landlocked suitavg *.continent) nonumbers r2 sca(N F) sfmt(0 3 3) mtitles("(1)" "(2)" "(3)" "(4)" "(5)" "(6)") label nodep nogaps compress star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) nonotes addnotes(" p < 0.10, ** p < 0.05, *** p < 0.01" "Huber-White robust standard errors in parentheses.") rtf replace
eststo clear


********************************************************************************
*		5.6.	Sensitivity to institutional determinants
********************************************************************************

eststo eq1: reg ictd_taxinsc statehiste01n catho80 muslim80 protmg80 ln_elev arable temp ln_precip cen_lat landlocked suitavg i.continent vdem_corr , r
estat ovtest
psacalc delta statehiste01n

eststo eq2: reg ictd_taxinsc statehiste01n catho80 muslim80 protmg80 ln_elev arable temp ln_precip cen_lat landlocked suitavg i.continent wbgi_gee , r
estat ovtest
psacalc delta statehiste01n

eststo eq3: reg ictd_taxinsc statehiste01n catho80 muslim80 protmg80 ln_elev arable temp ln_precip cen_lat landlocked suitavg i.continent fh_rol , r
estat ovtest
psacalc delta statehiste01n

eststo eq4: reg ictd_taxinsc statehiste01n catho80 muslim80 protmg80 ln_elev arable temp ln_precip cen_lat landlocked suitavg i.continent wbgi_pve , r
estat ovtest
psacalc delta statehiste01n

eststo eq5: reg ictd_taxinsc statehiste01n catho80 muslim80 protmg80 ln_elev arable temp ln_precip cen_lat landlocked suitavg i.continent vdem_egaldem , r
estat ovtest
psacalc delta statehiste01n


esttab using table7, se title(Table 7. Effect of State history, adding institutional determinants – OLS) drop(catho80 muslim80 protmg80 ln_elev arable temp ln_precip cen_lat landlocked suitavg *.continent) nonumbers r2 sca(N F) sfmt(0 3 3) mtitles("(1)" "(2)" "(3)" "(4)") label nodep nogaps compress star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) nonotes addnotes(" p < 0.10, ** p < 0.05, *** p < 0.01" "Huber-White robust standard errors in parentheses.") rtf replace
eststo clear


********************************************************************************
*		5.7.	Sensitivity to socio-demographic determinants 
********************************************************************************

eststo eq1: reg ictd_taxinsc statehiste01n catho80 muslim80 protmg80 ln_elev arable temp ln_precip cen_lat landlocked suitavg i.continent pwt_hci , r
estat ovtest
psacalc delta statehiste01n

eststo eq2: reg ictd_taxinsc statehiste01n catho80 muslim80 protmg80 ln_elev arable temp ln_precip cen_lat landlocked suitavg i.continent wdi_popurb , r
estat ovtest
psacalc delta statehiste01n

eststo eq3: reg ictd_taxinsc statehiste01n catho80 muslim80 protmg80 ln_elev arable temp ln_precip cen_lat landlocked suitavg i.continent wdi_popden , r
estat ovtest
psacalc delta statehiste01n

eststo eq4: reg ictd_taxinsc statehiste01n catho80 muslim80 protmg80 ln_elev arable temp ln_precip cen_lat landlocked suitavg i.continent wdi_lfprf , r
estat ovtest
psacalc delta statehiste01n


esttab using Table8, se title(Table 8. Effect of State History, adding socio-geographic Determinants – OLS) nonumbers r2 sca(N F) sfmt(0 3 3) mtitles("(1)" "(2)" "(3)" "(4)") label nodep nogaps compress star(* 0.10 ** 0.05 *** 0.01) b(%10.3f) nonotes addnotes(" p < 0.10, ** p < 0.05, *** p < 0.01" "Huber-White robust standard errors in parentheses.") replace rtf

eststo clear

********************************************************************************
*
********************************************************************************


xi: ivreg2 ictd_taxinsc (statehiste01n = mean_relgendist_fst_1500_UK mt1 )  catho80 muslim80 protmg80 ln_elev arable temp ln_precip cen_lat landlocked suitavg i.continent, r endog(statehiste01n) sfirst savefirst
est restore _ivreg2_statehiste01n

outreg2 using "ivreg2_1", e(Fp N idp widstat jp arfp) label dec(3) excel append replace

xi: ivreg2 ictd_taxinsc (statehiste01n = mean_relgendist_fst_1500_UK mt1 )  catho80 muslim80 protmg80 ln_elev arable temp ln_precip cen_lat landlocked suitavg i.continent, r endog(statehiste01n) first sfirst savefirst
outreg2 using "ivreg2_1", e(Fp N N_g idp widstat jp estatp arfp) label dec(3) excel append

xi: ivreg2 ictd_taxinsc (statehiste001n = mean_relgendist_fst_1500_UK mt1)  catho80 muslim80 protmg80 ln_elev arable temp ln_precip cen_lat landlocked suitavg i.continent, r endog(statehiste001n) sfirst savefirst gmm2s
est restore _ivreg2_statehiste001n

outreg2 using "ivreg2_1", e(Fp N idp widstat jp arfp) label dec(3) excel append 

xi: ivreg2 ictd_taxinsc (statehiste001n = mean_relgendist_fst_1500_UK mt1 )  catho80 muslim80 protmg80 ln_elev arable temp ln_precip cen_lat landlocked suitavg i.continent, r endog(statehiste001n) sfirst savefirst gmm2s
outreg2 using "ivreg2_1", e(Fp N N_g idp widstat jp estatp arfp) label dec(3) excel append

xi: ivreg2 ictd_taxinsc (statehiste02n = mean_relgendist_fst_1500_UK mt1 )  catho80 muslim80 protmg80 ln_elev arable temp ln_precip cen_lat landlocked suitavg i.continent, r endog(statehiste02n) sfirst savefirst gmm2s
est restore _ivreg2_statehiste02n

outreg2 using "ivreg2_1", e(Fp N idp widstat jp arfp) label dec(3) excel append 

xi: ivreg2 ictd_taxinsc (statehiste02n = mean_relgendist_fst_1500_UK mt1 )  catho80 muslim80 protmg80 ln_elev arable temp ln_precip cen_lat landlocked suitavg i.continent, r endog(statehiste02n) sfirst savefirst gmm2s
outreg2 using "ivreg2_1", e(Fp N N_g idp widstat jp estatp arfp) label dec(3) excel append

xi: ivreg2 ictd_taxinsc (statehiste1500_01n = mean_relgendist_fst_1500_UK mt1 )  catho80 muslim80 protmg80 ln_elev arable temp ln_precip cen_lat landlocked suitavg i.continent, r endog(statehiste1500_01n) sfirst gmm2s savefirst
est restore _ivreg2_statehiste1500_01n

outreg2 using "ivreg2_1", e(Fp N idp widstat jp arfp) label dec(3) excel append

xi: ivreg2 ictd_taxinsc (statehiste1500_01n = mean_relgendist_fst_1500_UK mt1 )  catho80 muslim80 protmg80 ln_elev arable temp ln_precip cen_lat landlocked suitavg i.continent, r endog(statehiste1500_01n) sfirst gmm2s savefirst
outreg2 using "ivreg2_1", e(Fp N N_g idp widstat jp estatp arfp) label dec(3) excel append

xi: ivreg2 ictd_taxinsc (statehiste1_1950 = mean_relgendist_fst_1500_UK mt1 )  catho80 muslim80 protmg80 ln_elev arable temp ln_precip cen_lat landlocked suitavg i.continent, r endog(statehiste1_1950) sfirst gmm2s savefirst
est restore _ivreg2_statehiste1_1950

outreg2 using "ivreg2_1", e(Fp N idp widstat jp arfp) label dec(3) excel append

xi: ivreg2 ictd_taxinsc (statehiste1_1950 = mean_relgendist_fst_1500_UK mt1 )  catho80 muslim80 protmg80 ln_elev arable temp ln_precip cen_lat landlocked suitavg i.continent, r endog(statehiste1_1950) sfirst gmm2s savefirst
outreg2 using "ivreg2_1", e(Fp N N_g idp widstat jp estatp arfp) label dec(3) excel append


xi: ivreg2 ictd_taxinsc (s01n_mig1 = mean_relgendist_fst_1500_UK mt1 )  catho80 muslim80 protmg80 ln_elev arable temp ln_precip cen_lat landlocked suitavg i.continent, r endog(s01n_mig1) sfirst gmm2s savefirst
est restore _ivreg2_s01n_mig1

outreg2 using "ivreg2_1", e(Fp N idp widstat jp arfp) label dec(3) excel append

xi: ivreg2 ictd_taxinsc (s01n_mig1 = mean_relgendist_fst_1500_UK mt1 )  catho80 muslim80 protmg80 ln_elev arable temp ln_precip cen_lat landlocked suitavg i.continent, r endog(s01n_mig1) sfirst gmm2s savefirst
outreg2 using "ivreg2_1", e(Fp N N_g idp widstat jp estatp arfp) label dec(3) excel append













